package lianxi;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main20 {
    public static void main(String[]args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        while(n > 0) {
            while(sc.hasNextInt()) {
                list.add( sc.nextInt());
            }
            n--;
        }
        Collections.sort(list);
        int k = 0;
        int m = 0;
        for(int i=1; i<list.size();i++) {
            //重复的数
            if(list.get(i)==list.get(i-1)) {
                k = list.get(i);
            }
            if(list.get(i) >= list.get(i-1)+2) {
                m = list.get(i)-1;
            }
            //断码的数
        }
        System.out.println(m + " " + k);
    }
}
